package org.groovymud.shell.security;

import java.security.Principal;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;

import org.groovymud.object.alive.Player;

public class MudLoginModuleData {
	public static final String GUEST_USER = "guest";
	public static final String PLAYER_PRINCIPAL = "player";
	
	public Subject subject;
	public CallbackHandler callbackHandler;
	public Map sharedState;
	public String username;
	public char[] password;
	public Player player;
	public Player dupe;
	public Set<Principal> playerPrincipals;
    boolean guest;

	public MudLoginModuleData(Subject subject, CallbackHandler callBackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
		this.subject = subject;
		this.callbackHandler = callBackHandler;
		this.sharedState = sharedState;
		this.playerPrincipals = new HashSet<Principal>();
		getPlayerPrincipals().add(createPrincipal(GUEST_USER));
		guest = false;
	}

	protected MudPrincipal createPrincipal(String principal) {
		return new MudPrincipal(principal);
	}

	/**
	 * @return the subject
	 */
	public Subject getSubject() {
		return subject;
	}

	
	/**
	 * @param subject the subject to set
	 */
	public void setSubject(Subject subject) {
		this.subject = subject;
	}

	
	/**
	 * @return the callbackHandler
	 */
	public CallbackHandler getCallbackHandler() {
		return callbackHandler;
	}

	
	/**
	 * @param callbackHandler the callbackHandler to set
	 */
	public void setCallbackHandler(CallbackHandler callbackHandler) {
		this.callbackHandler = callbackHandler;
	}

	
	/**
	 * @return the sharedState
	 */
	public Map getSharedState() {
		return sharedState;
	}

	
	/**
	 * @param sharedState the sharedState to set
	 */
	public void setSharedState(Map sharedState) {
		this.sharedState = sharedState;
	}

	
	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	
	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	
	/**
	 * @return the password
	 */
	public char[] getPassword() {
		return password;
	}

	
	/**
	 * @param password the password to set
	 */
	public void setPassword(char[] password) {
		this.password = password;
	}

	
	/**
	 * @return the player
	 */
	public Player getPlayer() {
		return player;
	}

	
	/**
	 * @param player the player to set
	 */
	public void setPlayer(Player player) {
		this.player = player;
	}

	
	/**
	 * @return the dupe
	 */
	public Player getDupe() {
		return dupe;
	}

	
	/**
	 * @param dupe the dupe to set
	 */
	public void setDupe(Player dupe) {
		this.dupe = dupe;
	}

	
	/**
	 * @return the playerPrincipals
	 */
	public Set<Principal> getPlayerPrincipals() {
		return playerPrincipals;
	}

	
	/**
	 * @param playerPrincipals the playerPrincipals to set
	 */
	public void setPlayerPrincipals(Set<Principal> playerPrincipals) {
		this.playerPrincipals = playerPrincipals;
	}

	
	/**
	 * @return the guest
	 */
	public boolean isGuest() {
		return guest;
	}

	
	/**
	 * @param guest the guest to set
	 */
	public void setGuest(boolean guest) {
		this.guest = guest;
	}

}
